package org.imaginedays.androidall.fragment;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.widget.ProgressBar;

/**
 * 旋转加载fragment
 * 
 * @author imaginedays
 * 
 */
public class RotationFragment extends Fragment {
	
	private Callbacks mCallbacks;
	
	private FragmentManager mFM;
	
	public interface Callbacks{
		public void onTaskFinished();
	}
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mFM = getFragmentManager();
		
		
		
	}
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		
		if (!(activity instanceof Callbacks)) {
			throw new IllegalStateException("Activity must implement fragment's callbacks.");
		}
		
		mCallbacks = (Callbacks) activity;
		
	}
	
	public static class TaskFragment extends DialogFragment{
		MyTask mTask;
		ProgressBar mProgressBar;
		
		public void setTask(MyTask task){
			mTask = task;
			mTask.setFragment(this);
		}
		
		@Override
		public void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setRetainInstance(true);
		}
		
		
	}
	
	public static class MyTask extends AsyncTask<Void, Void, Void>{

		TaskFragment mTaskFragment;
		
		
		@Override
		protected Void doInBackground(Void... params) {
			return null;
		}


		public void setFragment(Fragment taskFragment) {
			
		}
		
	}

}
